package oj;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 郝文雪
 * @date 2022/8/9 22:58
 * @Description Test
 */
class Node3 {
    public int val;
    public List<Node3> children;

    public Node3() {}

    public Node3(int _val) {
        val = _val;
    }

    public Node3(int _val, List<Node3> _children) {
        val = _val;
        children = _children;
    }
};
public class LC589 {
    List<Integer> list=new ArrayList<>();
    public List<Integer> preorder(Node3 root) {
        if(root==null) return list;
        pre(root);
        return list;
    }
    public void pre(Node3 root){
        List<Node3> children=root.children;
        if(root==null) return;
        list.add(root.val);
        for(int i=0;i<children.size();i++){
            pre(children.get(i));
        }
    }
}
